chrome.extension.onMessage.addListener(function (request, sender, sendMessage) {
    if (request.greeting == "download") {
        console.log("dddd")
        var video = document.getElementById("video");
        if (video) {
            var author = document.getElementsByClassName("artistBox")[0].innerText;
            var name = document.getElementsByClassName("videoName")[0].innerText;
            var type = video.src.substr(video.src.lastIndexOf("."));
            type = type.substr(0, type.indexOf("?"));
            name = author.replace(/\s+/g, "") + "_" + name.replace(/\s+/g, "") + type;

            sendMessage({
                url: video.src,
                filename: name
            });
        }
    }
});

